package com.muyu.common.core.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author Administrator
 */

@AllArgsConstructor
@Getter
public enum OrderByTypeEnum {

    DESC(1,"desc"), ASC(2,"asc");

    @JsonValue
    private final int code;

    private final String name;

    @JsonCreator
    public static OrderByTypeEnum getByCode(int code) {
        for (OrderByTypeEnum value : OrderByTypeEnum.values()) {
            if (value.code == code) {
                return value;
            }
        }
        return null;
    }
}
